﻿using System;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using UDS.Components;

namespace UDS.SubModule.Schedule
{
    /// <summary>
    /// TaskStatus 的摘要说明。
    /// </summary>
    public partial class TaskStatusPage : Page
    {
        protected static string Date;
        protected static string TaskID, Username;

        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Username = SiteContext.Current.UserName;
                TaskID = (Request.QueryString["TaskID"] != null) ? Request.QueryString["TaskID"] : "0";
                Date = (Request.QueryString["Date"] != null) ? Request.QueryString["Date"] : DateTime.Today.ToShortDateString();
                var task = new Task();
                TaskClass tsk = task.GetTaskDetail(Int32.Parse(TaskID));
                SqlDataReader dataReader = task.GetTaskStatus(Int32.Parse(TaskID));
                dgList.DataSource = dataReader;
                dgList.DataBind();
                dataReader.Close();
                PopulateData(tsk);
                TaskCommentFrm.Attributes["src"] = "TaskComment.aspx?TaskID=" + TaskID;
            }

            base.OnLoad(e);
        }


        public string GetStatus(string str)
        {
            switch (str)
            {
                case "0":
                    return "?"; // 待定
                case "1":
                    return "√"; // 待办
                case "2":
                    return "已完成"; // 完成
                default:
                    return "";
            }
        }

        public string GetRealName(string username)
        {
            if (username != "")
            {
                return Components.Staff.GetRealNameByUsername(username);
            }
            return "";
        }

        private void PopulateData(TaskClass tsk)
        {
            //			string Type="";
            //
            //			switch (tsk.Type) 
            //			{
            //				case 1:
            //					Type="会议";
            //					break;
            //				case 2:
            //					Type="文案";
            //					break;
            //				case 3:
            //					Type="来访";
            //					break;
            //				case 4:
            //					Type="电话";
            //					break;
            //				case 5:
            //					Type="走访";
            //					break;
            //				case 6:
            //					Type="外出";
            //					break;
            //				case 7:
            //					Type="假期";
            //					break;
            //				case 8:
            //					Type="出差";
            //					break;
            //			
            //			}
            //			


            lblArrangedBy.Text = Components.Staff.GetRealNameByUsername(tsk.ArrangedBy);
            //this.lblCooperator .Text    = tsk.CooperatorList ;
        }
    }
}